//
//  KLHotaldetailTableViewCell.m
//  KunLun
//
//  Created by Mac on 2017/11/28.
//  Copyright © 2017年 stoneobs@icloud.com. All rights reserved.
//

#import "KLMyChannelTableViewCell.h"

@interface KLMyChannelTableViewCell()
@property(nonatomic, strong) STLabel                            *titleLable;
@property(nonatomic, strong) STLabel                            *addLable;//订单号
@property(nonatomic, strong) STLabel                            *nameLbale;//id
@property(nonatomic, strong) STLabel                            *phoneLbale;//id
@property(nonatomic, strong) STLabel                            *statusLbale;//id
@property(nonatomic, strong) NSMutableArray                     *typeArray;//商家类型
@end
@implementation KLMyChannelTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self ==[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 150;
}
#pragma mark --subView
- (void)configSubView{
    
    self.backgroundColor = [UIColor whiteColor];
    
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(10, 10 , UIScreenWidth - 20 - 80, 20)
                                                text:@"公司名字"
                                           textColor:KL_firstTextColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.titleLable];
    
    
    self.statusLbale = [[STLabel alloc] initWithFrame:CGRectMake(10, 10 , 60, 20)
                                                text:@"营业中"
                                           textColor:KL_redColor
                                                font:15
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentRight];
    self.statusLbale.right = UIScreenWidth - 10;
    [self addSubview:self.statusLbale];
    
    self.addLable = [[STLabel alloc] initWithFrame:CGRectMake(10, self.titleLable.bottom +5, UIScreenWidth  - 20, 20)
                                                text:@"地址"
                                           textColor:KL_secendTextColor
                                                font:14
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    [self addSubview:self.addLable];
    
    self.nameLbale = [[STLabel alloc] initWithFrame:CGRectMake( 10, self.addLable.bottom + 10, 100 , 20)
                                               text:@"石老板"
                                          textColor:KL_secendTextColor
                                               font:14
                                        isSizetoFit:NO
                                      textAlignment:NSTextAlignmentLeft];
    
    [self addSubview:self.nameLbale];
    
    
    self.phoneLbale = [[STLabel alloc] initWithFrame:CGRectMake( 10, self.addLable.bottom + 10, 100 , 20)
                                               text:@"石老板"
                                          textColor:KL_secendTextColor
                                               font:14
                                        isSizetoFit:NO
                                      textAlignment:NSTextAlignmentRight];
    self.phoneLbale.right = UIScreenWidth - 10;
    [self addSubview:self.phoneLbale];
    
    
}
- (void)setModel:(KLMychnelModel *)model{
    _model = model;
    
    self.nameLbale.text = model.name;
    self.addLable.text = model.address;
    if (model.is_business.integerValue == 1) {
        self.statusLbale.text = @"未营业";
    }else{
        self.statusLbale.text = @"营业中";
    }
    self.phoneLbale.text = model.phone;
    
    for (UIView * view in self.typeArray) {
        [view removeFromSuperview];
    }
    self.typeArray = [NSMutableArray new];
    for (int i = 0; i < model.classify.count; i ++) {
        NSDictionary * dic = model.classify[i];
        NSString * name = [dic valueForKey:@"classify_id"];
        CGFloat left = 15;
        STLabel * titleLable = [[STLabel alloc] initWithFrame:CGRectMake(left, self.phoneLbale.bottom + 10, UIScreenWidth, 30)
                                                         text:name
                                                    textColor:[UIColor whiteColor]
                                                         font:14
                                                  isSizetoFit:NO
                                                textAlignment:NSTextAlignmentCenter];
        titleLable.backgroundColor = KL_BlueBackGroundColor;
        titleLable.layer.cornerRadius = 5;
        titleLable.clipsToBounds = YES;
        [NSString lableAutoAdjustWitdhWithLabel:titleLable];
        titleLable.width =   titleLable.width + 16;
        [self addSubview:titleLable];
        [self.typeArray addObject:titleLable];
        left = titleLable.right + 15;
        if (titleLable.right > (UIScreenWidth - 15)) {
            titleLable.hidden = YES;
        }
    }

}
@end

